package com.hyb.algorithm.data.struct.str;

import java.util.HashSet;
import java.util.Set;

/**
 * @author: ybhu
 * @create: 2021/09/21 15:45
 *
 * 771. 宝石与石头
 * https://leetcode-cn.com/problems/jewels-and-stones/
 *
 *
 */
public class NumJewelsInStones {

    public int numJewelsInStones(String jewels, String stones) {

        int n=jewels.length();
        int m=stones.length();

        Set<Character> map=new HashSet<>();

        for(int i=0;i<n;i++){
            map.add(jewels.charAt(i));
        }



        int ret=0;
        //利用 hash map
        for(int j=0;j<m;j++){
            if(map.contains(stones.charAt(j))){
                ret++;
            }
        }


        return ret;
    }

}
